//一个创建thunk的中间件工厂函数
function createThunkMiddleware(extraArgument){
  return ({dispatch,getState})=>next=>action=>{
     if(typeof action === 'function'){
       return action(dispatch,getState,extraArgument)
     } 
     return next(action);
  }
}
//创建出thunk中间件
const thunk = createThunkMiddleware();
//把工厂函数附属到thunk对象上，方便高级用户自定义传入更多的参数到action中去
thunk.withExtraArgument = createThunkMiddleware;
export default thunk;